// 1. 引入vue
import Vue from 'vue'
// 2. 引入vue的路由模块
import VueRouter from 'vue-router'
// 3. 引入某一个页面组件
import Home from '../views/Home/index.vue'

// 4. 将vue的路由模块注册到vue
Vue.use(VueRouter)

// 5. 定义路由对象
const routes = [
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/cart',
    name: 'Cart',
    component: () => import(/* webpackChunkName: "cart" */ '../views/Cart/index.vue')
  },
  {
    path: '/kind',
    name: 'Kind',
    component: () => import(/* webpackChunkName: "kind" */ '../views/Kind/index.vue')
  },
  {
    path: '/my',
    name: 'My',
    component: () => import(/* webpackChunkName: "user" */ '../views/My/index.vue')
  }
]

// 6. 创建路由实例
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  // 7. 将路由对象添加到创建路由实例的配置选项
  routes
})

// 7. 将路由实例暴露
export default router
